package com.mysteel.search.web;

import com.mysteel.search.service.MailSearchService;
import com.mysteel.search.vo.SearchParams;
import com.mysteel.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * ProjectName: mail
 * ClassName: SearchController
 * Description:
 * date: 2021/01/28/028 19:18
 *
 * @author xiaochao
 */
@Controller
public class SearchController {

    @Autowired
    private MailSearchService mailSearchService;

    @GetMapping("/list.html")
    public String forwardToList(SearchParams params, Model model, HttpServletRequest request){
        String queryString = request.getQueryString();
        params.set_queryString(queryString);
        SearchResult result = mailSearchService.search(params);
        model.addAttribute("result",result);
        return "list";
    }
}
